/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2019-06-21 11:28:36
 * @Description: 首页-应用工具-手机归属地
 */
import { observable, action } from "mobx";
import resource from "@/utils/resource";
import API from "@/utils/api";
import { message } from "antd";

class IpLocationStore {
    @observable keyWords = "";
    @observable result = "";

    @action.bound
    changeKeyWords(keyWords) {
        this.keyWords = keyWords;
    }

    @action.bound
    getLocation() {
        const { keyWords } = this;
        if (keyWords === "") {
            message.error("请输入关键字");
            return;
        }

        resource
            .get(API.homeIpLocationSearch, {
                keyWords: this.keyWords
            })
            .then(res => {
                this.result = res.location;
            });
    }
}

export default new IpLocationStore();
